<template>
  <card class="card" title="编辑信息">
    <div>
      <form @submit.prevent>
        <div class="row">
          <div class="col-md-5">
            <fg-input type="text" label="身份" :disabled="true" placeholder="身份" v-model="user.ident">
            </fg-input>
          </div>
          <div class="col-md-3">
            <fg-input type="text" label="用户名" placeholder="用户名" v-model="user.username">
            </fg-input>
          </div>
          <div class="col-md-4">
            <fg-input type="email" label="邮箱地址" placeholder="邮箱地址" v-model="user.email">
            </fg-input>
          </div>
        </div>

        <div class="row">
          <div class="col-md-4">
            <fg-input type="text" label="工号" :disabled="true" placeholder="工号" v-model="user.id">
            </fg-input>
          </div>
          <div class="col-md-8">
            <fg-input type="text" label="工种" :disabled="true" placeholder="工种" v-model="user.type">
            </fg-input>
          </div>
        </div>

        <div class="row">
          <div class="col-md-12">
            <fg-input type="text" label="工作地点" :disabled="true" placeholder="工作地点" v-model="user.location">
            </fg-input>
          </div>
        </div>

        <div class="row">
          <div class="col-md-4">
            <fg-input type="text" :disabled="true" label="所属工作小组" placeholder="所属工作小组" v-model="user.classwork">
            </fg-input>
          </div>
          <div class="col-md-4">
            <fg-input type="text" label="电话号码" :disabled="true" placeholder="电话号码" v-model="user.phone">
            </fg-input>
          </div>
          <div class="col-md-4">
            <fg-input type="number" label="小组代号" :disabled="true" placeholder="小组代号" v-model="user.classid">
            </fg-input>
          </div>
        </div>

        <div class="row">
          <div class="col-md-12">
            <div class="form-group">
              <label>个性签名</label>
              <textarea rows="5" class="form-control border-input" placeholder="每个人都有自己的至理名言" v-model="user.aboutme">
              </textarea>
            </div>
          </div>
        </div>
        <div class="text-center">
          <p-button type="info" round @click.native.prevent="updateProfile">
            切换账号
          </p-button>
        </div>
        <div class="clearfix"></div>
      </form>
    </div>
  </card>
</template>
<script>
import NotificationTemplate from "../Notifications/NotificationTemplate";

export default {
  data() {
    return {
      type: ["", "info", "success", "warning", "danger"],
      notifications: {
        topCenter: false,
      },
      user: {
        ident: "心动健康管理员",
        username: this.$store.state.nowUsername,
        email: this.$store.state.nowEmail,
        id: this.$store.state.nowId,
        type: this.$store.state.nowType,
        location: this.$store.state.nowLocation,
        classwork: this.$store.state.nowClasswork,
        classid: this.$store.state.nowClassid,
        phone: this.$store.state.nowPhone,
        aboutme: this.$store.state.nowAboutme
      },
      flag: true
    };
  },
  methods: {
    updateProfile() {
      this.$parent.tmp()
      sessionStorage.setItem("logStatu","NOT")
    },
    notifyVue(verticalAlign, horizontalAlign, color) {
      // const color = Math.floor(Math.random() * 4 + 1);
      this.$notify({
        component: NotificationTemplate,
        icon: "ti-gift",
        horizontalAlign: horizontalAlign,
        verticalAlign: verticalAlign,
        type: this.type[color],
      });
    },
    renew() {

      this.user.id =  this.$store.state.nowId,
      this.user.username = this.$store.state.nowUsername ,
      this.user.status =  this.$store.state.nowStatus,
      this.user.email  = this.$store.state.nowEmail,
      this.user.type =  this.$store.state.nowType ,
      this.user.location = this.$store.state.nowLocation,
      this.user.classwork=this.$store.state.nowClasswork,
      this.user.phone =  this.$store.state.nowPhone ,
      this.user.classid = this.$store.state.nowClassid ,
      this.user.aboutme= this.$store.state.nowAboutme 

    }
  },

  onMounted() {
    this.renew()
    if (this.flag) {
      this.$forceUpdate
      this.flag = false
    }
  }
};
</script>
<style></style>
